package 笔试.四4399;

import java.util.Arrays;
import java.util.Scanner;

public class 两数之和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String numstr = sc.nextLine();
        String[] strs = numstr.split(" ");
        int[] nums = new int[strs.length];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(strs[i]);
        }
        int target = sc.nextInt();
        Solution solution = new Solution();
        // 3 9 12 15
        // 18
        int[] res = solution.twoSum(nums, target);
        System.out.println(Arrays.toString(res));
    }

    static class Solution {
        public int[] twoSum(int[] nums, int target) {
            int left = 0;
            int right = nums.length - 1;
            while (left < right) {
                int sum = nums[left] + nums[right];
                if (sum > target) {
                    right--;
                } else if (sum < target) {
                    left++;
                } else {
                    return new int[]{nums[left], nums[right]};
                }
            }
            return null;
        }
    }

}